package com.wq.recruit.controller;

import com.wq.common.entity.Result;
import com.wq.common.entity.StatusCode;
import com.wq.recruit.entity.Recruit;
import com.wq.recruit.service.RecruitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("recruit")
@CrossOrigin
public class RecruitController {
    @Autowired
    private RecruitService recruitService;

    @GetMapping("recommend")
    public Result findRecommend(@RequestParam(value = "state", defaultValue = "2") String state, @RequestParam(value = "size", defaultValue = "4") int size) {
        List<Recruit> recommend = recruitService.findRecommend(state, size);
        return new Result(true, StatusCode.OK, "推荐职位查询成功", recommend);
    }

    @GetMapping("latest")
    public Result findLatest(@RequestParam(value = "state", defaultValue = "0") String state, @RequestParam(value = "size", defaultValue = "12") int size) {
        List<Recruit> recommend = recruitService.findLatest(state, size);
        return new Result(true, StatusCode.OK, "最新职位查询成功", recommend);
    }

}